import operations.*;

import java.util.Scanner;

public class Main {
    private static IOperation[] iOperations;

    public static int menu() {
        System.out.println("=== 学生信息管理系统 ===");
        System.out.println("1 - 添加学生信息");
        System.out.println("2 - 删除学生信息");
        System.out.println("3 - 修改学生信息");
        System.out.println("4 - 查询学生信息");
        System.out.println("0 - 退出系统");
        while (true) {
            System.out.println("请输入你的操作：");
            Scanner in = new Scanner(System.in);
            int choice = in.nextInt();
            if (choice < 0 || choice > 5) {
                System.out.println("输入错误请重新输入！");
            } else {
                return choice;
            }
        }
    }

    public static void reg() {
        iOperations = new IOperation[] {
                new Exit(),
                new Add(),
                new Del(),
                new Modify(),
                new Search()
        };
    }

    public static void doOperation(int choice) {
        iOperations[choice].work();
    }

    public static void main(String[] args) {
        reg();
        while (true) {
            int choice = menu();
            doOperation(choice);
        }
    }
}
